Page({
  data:{
    i:0,
    gp:["gp0","gp1","gp2","gp3","gp4","gp5","gp6","gp7","gp8","gp9"],
    individual:{},
    hasined:false,
    orders:[{id:1,title:'键盘',image:'/images/666.png',detail:'双模键盘',price:'100'},]
  },
  
  onReady() {
    var self = this;
    wx.getStorage({
      key: 'individual',
      success: function(res){
        self.setData({
          individual:res.data,
          hasined:true
        })
      }
    });
    wx.getStorage({
      key:self.data.gp[self.data.i],
      success(res) {
        self.data.orders.push({id:self.data.i,title:res.data.title,image:'/images/666.png',
        detail:res.data.detail,price:res.data.price});
        self.setData({
          individual: res.data
        })
      }
    })
    const db = wx.cloud.database();
    const _ = db.command;
    db.collection('goods').where({
     name: _.eq(this.data.individual.name)
    })
    .get({
      success: function(res) {
        console.log(res.data);
        self.data.orders.push({id:self.data.i,title:res.data[0].title,image:'/images/666.png',
        detail:res.data[0].detail,price:res.data[0].price});
        self.setData({
          //orders:a,
          i:i+1
        });
      console.log(self.data.orders);
      }
    })
  },
  
  onShow:function(){
    const self = this;
    wx.getStorage({
      key:self.data.gp[self.data.i],
      success(res) {
        self.data.orders.push({id:self.data.i,title:res.data.title,image:'/images/666.png',
        detail:res.data.detail,price:res.data.price});
        self.setData({
          individual: res.data
        })
      }
    })
  }
})